/*
 * 模拟考试脚本
 */
var mocktbl = $('#mocktbl');
mocktbl.bootstrapTable({
    classes:'table table-hover',
    striped:true,
    idField:'id',
    showToggle:false,
    showColumns:false,
    showRefresh:false,
    sidePagination:'server',//数据从服务器加载
    columns:[{
        field:'name',
        title:'名称',
        align:'left'
    },{
        field:'createDate',
        title:'创建时间',
        align:'center'
    },{
        field:'examTime',
        title:'考试时长',
        align:'center'
    },{
        field:'score',
        title:'成绩',
        align:'center',
        formatter:function (value,row,index) {
            var score = "";
            $.ajax({
                type:'post',
                url:'front/student/getMockScore',
                data:{"examRoomId":row.id},
                dataType:'json',
                async:false,
                success:function (data) {
                    if(data.studentExamPaper){
                    	if(data.studentExamPaper.score == null){
                    		score = "-";
                    	}else{
                    		score = data.studentExamPaper.score;
                    		row.score = score;
                    	}
                    }else{
                    	score = "-";
                    }
                }
            });
            return '<span style="color: red;font-weight: bolder">'+score+'</span>';
        }
    },{
        field:'operation',
        title:'操作',
        align:'center',
        formatter:function (value,row,index) {
        	console.log(row.score);
            if(row.score == null){
                link = '<a href="front/student/view/'+row.id+'/'+row.exampaper_id+'">开始考试</a>';
            }else{
                link = '<a href="front/student/analysisPaper?paper_id='+row.exampaper_id+'">查看解析</a>';
            }
            return link;
        }
    }],
    url:'front/student/mock',
    pagination:true,
    pageNumber:1,
    pageSize:20,
    pageList:[5,20,30,40,50],
});
